package vip.specimen.system.datasource.entity.question;

import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.elasticsearch.annotations.Document;
import vip.specimen.system.common.enums.QuestionTypeEnum;
import vip.specimen.system.datasource.entity.BaseEntity;

import javax.persistence.*;

/**
 * *@Author: 余浪人
 * *@Date：2021/4/22 16:59
 * *@Email:yulangren520@Gmail.com
 * *@QQ:1368419640
 **/
@Setter
@Getter
@Entity
@Table(name = "question_problem")
@Document(indexName = "question_problem")
public class QuestionProblemEntity extends BaseEntity {
    @Column(length = 2147483647)
    @ApiModelProperty(value = "问题")
    private String problem;
    @Column(length = 2147483647)
    @ApiModelProperty(value = "答案")
    private String result;
    @Column(length = 2147483647)
    @ApiModelProperty(value = "解析")
    private String analysis;
    @ApiModelProperty(value = "点击数")
    private Integer click;
    @ApiModelProperty(value = "是否付费")
    private Boolean isPay = Boolean.FALSE;
    @ApiModelProperty(value = "付费金额")
    private Double pay = 0.00;
    @ApiModelProperty(value = "问题类型")
    @Enumerated(EnumType.STRING)
    private QuestionTypeEnum questionType;
    @ApiModelProperty(value = "问题分类")
    @ManyToOne(fetch = FetchType.EAGER)
    @JoinTable(name = "question_problem_column", joinColumns = {@JoinColumn(name = "problem_uuid")}, inverseJoinColumns = {@JoinColumn(name = "column_uuid")})
    private QuestionColumnEntity categories;

    public QuestionProblemEntity() {
    }

    public QuestionProblemEntity(String problem, String result, String analysis, Integer click, Boolean isPay, Double pay, QuestionTypeEnum questionType, QuestionColumnEntity categories) {
        this.problem = problem;
        this.result = result;
        this.analysis = analysis;
        this.click = click;
        this.isPay = isPay;
        this.pay = pay;
        this.questionType = questionType;
        this.categories = categories;
    }
}
